﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using ApiManage.Core.Repository.MongoDB;
using ApiManage.Models.MongoMappings.Project;
using Rhonin.Common.Components;

namespace ApiManage.Service.Mongo.Project.Impl
{
    [Component(LifeStyle.Singleton)]
    public class ProjectQueryService : IProjectQueryService
    {
        private readonly IProjectRepository<Projects> _projectRepository;
        public ProjectQueryService(IProjectRepository<Projects> projectRepository)
        {
            _projectRepository = projectRepository;
        }

        public Projects Get(Expression<Func<Projects, bool>> where)
        {
            return _projectRepository.GetQuery().FirstOrDefault(where);
        }

        public List<Projects> GetList(Expression<Func<Projects, bool>> where)
        {
            return _projectRepository.GetQuery().Where(where).ToList();
        }
    }
}
